package ru.hh.school.util;

import java.util.Iterator;

public class StringUtils {
    public static String join(Iterable<String> strings, String separator) {
        if (strings == null) {
            return null;
        }
        Iterator<String> iterator = strings.iterator();
        if (separator == null) {
            separator = "";
        }

        StringBuilder builder = new StringBuilder();
        while (iterator.hasNext()) {
            String str = iterator.next();
            builder.append(str);
            if (iterator.hasNext()) {
                builder.append(separator);
            }
        }
        return builder.toString();
    }
}